home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '90 / Utilities ƒ / MPW Tools ƒ / Simula4.07 / Simula 4.07ƒ / SInterfaces / defaultMenuProcess.sim < prev    next >
Encoding:
Text File  |  1989-04-24  |  1.5 KB  |  50 lines  |  [TEXT/MPS ]

  1. % ---------------------------------------------------------------------------
  2. %    Class DefaultMenuProcess
  3. %
  4. % Part of the Lund Software interface to Macintosh Toolbox
  5. % DefaultMenuProcess is designed to act as a process under the
  6. % MACProcessMGR. It receives events marked as "inMenuBar" and
  7. % will activate the appropriate menu.
  8. %
  9. % 890412/Boris Magnusson
  10. %
  11. % ---------------------------------------------------------------------------
  12. External class MacPoint="::Sinterfaces:MacPoint";
  13. External class MacEvent="::Sinterfaces:MacEvent";
  14. External class MacProcess="::SInterfaces:MacProcess";
  15. External class MacMenuBar="::SInterfaces:MacMenuBar";
  16. MacProcess class DefaultMenuProcess(bar); 
  17.     ref(macmenubar) bar;
  18. begin
  19.     integer find; ! result code from "findWindow" ;
  20.     integer menu_item,menuId,item; ! menuSelect result;
  21.     ref(macEvent) myevent;
  22.     ref(macpoint) aPoint;
  23.     aPoint:-new macPoint;
  24.     myEvent:- new MacEvent;
  25.     enableEvent(TConst.mouseDown);
  26.     enableEvent(Tconst.keydown);
  27.  
  28.     while true do
  29.     begin
  30.         find:=waitnextevent(myEvent); ! wait for next event targeted at bar;
  31.         if find=Tconst.inMenubar then
  32.         begin
  33.             myEvent.copypoint(aPoint);
  34.             menu_item:=bar.MenuSelect(aPoint);
  35.         end
  36.         else if util.bitAnd(myEvent.modifiers,TConst.cmdKey)<>0 then
  37.             menu_item:=bar.menukey(
  38.                 char(Util.bitAnd(myEvent.message,tconst.charcodemask)))
  39.         else
  40.             menu_item:=0;
  41.         MenuID:=util.hiWord(menu_item);
  42.         item:=Util.loWord(menu_item);
  43.         if MenuID<>0 then
  44.         begin
  45.             bar.findmenu(MenuID).doMenu(menuID,item);
  46.             bar.hiliteMenu(0);
  47.         end;
  48.     end -- for ever -- ;
  49.     
  50. END --- Default Menu Process --- ;